home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / CBASE102.ARJ / CBGETRCU.C < prev    next >
Text File  |  1991-09-23  |  2KB  |  88 lines

  1. /*    Copyright (c) 1989 Citadel    */
  2. /*       All Rights Reserved        */
  3.  
  4. /* #ident    "@(#)cbgetrcu.c    1.5 - 91/09/23" */
  5.  
  6. #include <ansi.h>
  7.  
  8. /* ansi headers */
  9. #include <errno.h>
  10.  
  11. /* library headers */
  12. #include <blkio.h>
  13. #include <lseq.h>
  14.  
  15. /* local headers */
  16. #include "cbase_.h"
  17.  
  18. /*man---------------------------------------------------------------------------
  19. NAME
  20.      cbgetrcur - get cbase record cursor
  21.  
  22. SYNOPSIS
  23.      #include <cbase.h>
  24.  
  25.      int cbgetrcur(cbp, cbrposp)
  26.      cbase_t *cbp;
  27.      cbrpos_t *cbrposp;
  28.  
  29. DESCRIPTION
  30.      The cbgetrcur function gets the position of the record cursor of
  31.      cbase cbp.  The cursor position is returned in the location
  32.      pointed to by cbrposp.
  33.  
  34.      cbgetrcur will fail if one or more of the following is true:
  35.  
  36.      [EINVAL]       cbp is not a valid cbase pointer.
  37.      [EINVAL]       cbrposp is the NULL pointer.
  38.      [CBELOCK]      cbp is not locked.
  39.      [CBENOPEN]     cbp is not open.
  40.  
  41. SEE ALSO
  42.      cbgetkcur, cbrcursor, cbsetrcur.
  43.  
  44. DIAGNOSTICS
  45.      Upon successful completion, a value of 0 is returned.  Otherwise,
  46.      a value of -1 is returned, and errno set to indicate the error.
  47.  
  48. ------------------------------------------------------------------------------*/
  49. #ifdef AC_PROTO
  50. int cbgetrcur(cbase_t *cbp, cbrpos_t *cbrposp)
  51. #else
  52. int cbgetrcur(cbp, cbrposp)
  53. cbase_t *cbp;
  54. cbrpos_t *cbrposp;
  55. #endif
  56. {
  57.     lspos_t lspos = NIL;
  58.  
  59.     /* validate arguments */
  60.     if (!cb_valid(cbp) || cbrposp == NULL) {
  61.         errno = EINVAL;
  62.         return -1;
  63.     }
  64.  
  65.     /* check if not open */
  66.     if (!(cbp->flags & CBOPEN)) {
  67.         errno = CBENOPEN;
  68.         return -1;
  69.     }
  70.  
  71.     /* check if not locked */
  72.     if (!(cbp->flags & CBLOCKS)) {
  73.         errno = CBELOCK;
  74.         return -1;
  75.     }
  76.  
  77.     /* get record cursor position */
  78.     if (lsgetcur(cbp->lsp, &lspos) == -1) {
  79.         CBEPRINT;
  80.         return -1;
  81.     }
  82.  
  83.     /* load return argument */
  84.     *cbrposp = lspos;
  85.  
  86.     return 0;
  87. }
  88.